package com.qf.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;

public class User {

    private Integer id;

    private String name;

    private Boolean gender;

    @DateTimeFormat(pattern = "yyyy-MM-dd") // 注意，这个注解不会影响返回的json中的日期的格式
    @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")  // 设置json的日期格式，使用的时区为东8区
    private Date birth;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Boolean getGender() {
        return gender;
    }

    public void setGender(Boolean gender) {
        this.gender = gender;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    @Override
    public String toString() {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return "User{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", gender=" + gender +
                ", birth=" + simpleDateFormat.format(birth) +
                '}';
    }
}
